package com.decade.service.impl;

import com.decade.mapper.GoodsMapper;
import com.decade.pojo.Goods;
import com.decade.service.GoodsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class GoodsServiceImpl implements GoodsService {
    private static final Logger log =
            LoggerFactory.getLogger(GoodsService.class);
    @Autowired
    private GoodsMapper goodsMapper;
    @Override
    public List<Goods> findGoods(Goods goods) {
        log.info("查询Goods");
        log.info("start{}", System.currentTimeMillis());
        List<Goods> list = goodsMapper.findGoods(goods);
        log.info("end{}", System.currentTimeMillis());
        return list;
    }

    @Override
    public Goods findGoodsById(Integer id) {
        log.info("查询GoodsById");
        log.info("start{}", System.currentTimeMillis());
        Goods goods = goodsMapper.findGoodsById(id);
        log.info("end{}", System.currentTimeMillis());
        return goods;
    }

    @Override
    public Integer addGoods(Goods goods) {
        log.info("添加Goods");
        log.info("start{}", System.currentTimeMillis());
        int row = goodsMapper.addGoods(goods);
        log.info("end{}", System.currentTimeMillis());
        return row;
    }

    @Override
    public Integer updateGoods(Goods goods) {
        log.info("修改Goods");
        log.info("start{}", System.currentTimeMillis());
        int row = goodsMapper.updateGoods(goods);
        log.info("end{}", System.currentTimeMillis());
        return row;
    }

    @Override
    public Integer delGoods(Integer id) {
        log.info("删除Goods");
        log.info("start{}", System.currentTimeMillis());
        int row = goodsMapper.delGoods(id);
        log.info("end{}", System.currentTimeMillis());
        return row;
    }
}
